home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 903 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: news.compuserve.com!newsmaster
  2. From: 100754.2730@compuserve.com (Martin Aupperle)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: beginner question - typecasting
  5. Date: Mon, 08 Jan 1996 08:08:21 GMT
  6. Organization: CompuServe Incorporated
  7. Message-ID: <4cqjq4$337@dub-news-svc-1.compuserve.com>
  8. References: <4cei1r$s02@sun.cis.smu.edu> <30EAFDFC.BF0@softint.com>
  9. NNTP-Posting-Host: ad35-142.compuserve.com
  10. X-Newsreader: Forte Free Agent v0.56
  11.  
  12. Rud Merriam <rmerriam@softint.com> wrote:
  13.  
  14. >> The specific example given is:
  15. >> 
  16. >> int i = 2;
  17. >> float a, b;
  18. >> a = float(i);
  19. >> b = (float) i;
  20. >> 
  21. >> In this example, would a and b return the same value and have the same
  22. >> data type (float)?
  23.  
  24. >Yes they would. Use the functional notation because it is more easily 
  25. >understood, IMO. Potentially the (float) form could be eliminated from the 
  26. >language sometime in the future.
  27.  
  28. Hopefully not! The second form is the only one possible if the target
  29. type consists of more than one keyword, e.g.
  30.  
  31.   void f ( const void* p ) {
  32.     const char *str = (const char*)p;
  33.    
  34.     /* ... */
  35.     }
  36.  
  37. I know that this is a type cast and not a conversion. 
  38.  
  39.  
  40.  
  41. -----------------------------------
  42. Signatures are a waste of bandwidth
  43. -----------------------------------
  44.  
  45.